<?php

class DetenidoDB extends CI_Model {

    var $title = '';
    var $content = '';
    var $date = '';

    function __construct() {
        // Call the Model constructor
        parent::__construct();
    }

    function get_last_ten_entries() {
        $query = $this->db->get('entries', 10);
        return $query->result();
    }

    function Insert_Tabl($arrData) {
        //$this->db->insert('vigilantes', $arrData);
        
        if(!empty($arrData["f_nac"]))
            $this->db->insert('per_det', $arrData);
        else{
            $arrData["f_nac"] = NULL;
            $this->db->insert('per_det', $arrData);
        }
    }  
       
    function borrar_tabladetenido($item) {
        /*$this->db->where('ficha', $item['eliminar']);
        $this->db->delete('empleado');      */ 
        
        $q = $this->db->get_where('per_det', array('ci' => $item['eliminar']));
            if ($q->result()) {
            $this->db->where('ci',$item['eliminar']);
            $this->db->delete('per_det');
            return TRUE;
            } else { 
            return FALSE;
            }
    }
    
    function update_entrydet($arrData) {
        
        $this->db->where('ci', $arrData['ci']);
        $q = $this->db->get('per_det');

        if ($q->num_rows() > 0) {
            $this->db->where('ci', $arrData['ci']);
            $this->db->update('per_det', $arrData);
            return TRUE;
        }else FALSE;
    }

}
